package cn.marinda.resturants.annotation.impl;

import cn.marinda.resturants.annotation.AdministratorAnnotation;
import cn.marinda.resturants.annotation.StaffAnnotation;
import cn.marinda.resturants.annotation.UserAnnotation;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

/** 定义RoleAnnotation 注解处理器
 * @data 2021/11/24
 * @author Marinda
 * @version 1.0
 */
@Component
public class RoleAnnotationImpl {

    /** 获取身份数据
     * @param roleClass  角色类
     * @return 验证结果
     */
    public String validRoleName(Class roleClass)
    {
        List<Annotation> annotationList = new ArrayList<>();
//        储存注解
        annotationList.add(roleClass.getAnnotation(UserAnnotation.class));
        annotationList.add(roleClass.getAnnotation(StaffAnnotation.class));
        annotationList.add(roleClass.getAnnotation(AdministratorAnnotation.class));
        for(Annotation annotation : annotationList){
           for(Annotation annotation1 : roleClass.getAnnotations()){
               if(annotation1.annotationType().equals(annotation.annotationType())){
                   System.out.println("Name: "+ annotation.annotationType().getName());
                   return annotation.annotationType().getName();
               }
           }
        }
        return null;
    }

    /** 通过角色处理权限跳过
     */

}
